6dofimu26 2.2.1
Loading...
Searching...
No Matches
c6dofimu26.h
Go to the documentation of this file.
1/****************************************************************************
2** Copyright (C) 2026 MikroElektronika d.o.o.
3** Contact: https://www.mikroe.com/contact
4**
5** Permission is hereby granted, free of charge, to any person obtaining a copy
6** of this software and associated documentation files (the "Software"), to deal
7** in the Software without restriction, including without limitation the rights
8** to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9** copies of the Software, and to permit persons to whom the Software is
10** furnished to do so, subject to the following conditions:
11** The above copyright notice and this permission notice shall be
12** included in all copies or substantial portions of the Software.
13**
14** THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
16** OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
17** IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
18** DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT
19** OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
20** USE OR OTHER DEALINGS IN THE SOFTWARE.
21****************************************************************************/
22
27
28#ifndef C6DOFIMU26_H
29#define C6DOFIMU26_H
30
31#ifdef __cplusplus
32extern "C"{
33#endif
34
39#ifdef PREINIT_SUPPORTED
40#include "preinit.h"
41#endif
42
43#ifdef MikroCCoreVersion
44 #if MikroCCoreVersion >= 1
45 #include "delays.h"
46 #endif
47#endif
48
49#include "drv_digital_out.h"
50#include "drv_digital_in.h"
51#include "drv_spi_master.h"
52#include "spi_specifics.h"
53
59
64
69
74#define C6DOFIMU26_REG_RATE_X1 0x01
75#define C6DOFIMU26_REG_RATE_Y1 0x02
76#define C6DOFIMU26_REG_RATE_Z1 0x03
77#define C6DOFIMU26_REG_ACC_X1 0x04
78#define C6DOFIMU26_REG_ACC_Y1 0x05
79#define C6DOFIMU26_REG_ACC_Z1 0x06
80#define C6DOFIMU26_REG_ACC_X3 0x07
81#define C6DOFIMU26_REG_ACC_Y3 0x08
82#define C6DOFIMU26_REG_ACC_Z3 0x09
83#define C6DOFIMU26_REG_RATE_X2 0x0A
84#define C6DOFIMU26_REG_RATE_Y2 0x0B
85#define C6DOFIMU26_REG_RATE_Z2 0x0C
86#define C6DOFIMU26_REG_ACC_X2 0x0D
87#define C6DOFIMU26_REG_ACC_Y2 0x0E
88#define C6DOFIMU26_REG_ACC_Z2 0x0F
89#define C6DOFIMU26_REG_TEMP 0x10
90#define C6DOFIMU26_REG_RATE_DCNT 0x11
91#define C6DOFIMU26_REG_ACC_DCNT 0x12
92#define C6DOFIMU26_REG_FREQ_CNTR 0x13
93#define C6DOFIMU26_REG_STAT_SUM 0x14
94#define C6DOFIMU26_REG_STAT_SUM_SAT 0x15
95#define C6DOFIMU26_REG_STAT_COM 0x16
96#define C6DOFIMU26_REG_STAT_RATE_COM 0x17
97#define C6DOFIMU26_REG_STAT_RATE_X 0x18
98#define C6DOFIMU26_REG_STAT_RATE_Y 0x19
99#define C6DOFIMU26_REG_STAT_RATE_Z 0x1A
100#define C6DOFIMU26_REG_STAT_ACC_X 0x1B
101#define C6DOFIMU26_REG_STAT_ACC_Y 0x1C
102#define C6DOFIMU26_REG_STAT_ACC_Z 0x1D
103#define C6DOFIMU26_REG_STAT_SYNC_ACTIVE 0x1E
104#define C6DOFIMU26_REG_STAT_INFO 0x1F
105#define C6DOFIMU26_REG_CTRL_FILT_RATE 0x25
106#define C6DOFIMU26_REG_CTRL_FILT_ACC12 0x26
107#define C6DOFIMU26_REG_CTRL_FILT_ACC3 0x27
108#define C6DOFIMU26_REG_CTRL_RATE 0x28
109#define C6DOFIMU26_REG_CTRL_ACC12 0x29
110#define C6DOFIMU26_REG_CTRL_ACC3 0x2A
111#define C6DOFIMU26_REG_CTRL_USER_IF 0x33
112#define C6DOFIMU26_REG_CTRL_ST 0x34
113#define C6DOFIMU26_REG_CTRL_MODE 0x35
114#define C6DOFIMU26_REG_CTRL_RESET 0x36
115#define C6DOFIMU26_REG_SYS_TEST 0x37
116#define C6DOFIMU26_REG_SPARE_1 0x38
117#define C6DOFIMU26_REG_SPARE_2 0x39
118#define C6DOFIMU26_REG_SPARE_3 0x3A
119#define C6DOFIMU26_REG_ASIC_ID 0x3B
120#define C6DOFIMU26_REG_COMP_ID 0x3C
121#define C6DOFIMU26_REG_SN_ID1 0x3D
122#define C6DOFIMU26_REG_SN_ID2 0x3E
123#define C6DOFIMU26_REG_SN_ID3 0x3F
124 // c6dofimu26_reg
126
131
136
141#define C6DOFIMU26_D_BIT 0x80
142#define C6DOFIMU26_RW_BIT 0x20
143#define C6DOFIMU26_FT_48_BIT 0x08
144
149#define C6DOFIMU26_SYS_TEST 0x55AA
150
155#define C6DOFIMU26_CTRL_MODE_EOI_CTRL 0x0003
156#define C6DOFIMU26_CTRL_MODE_EN_SENSOR 0x0001
157
162#define C6DOFIMU26_ACCEL_LSB_RES 3200
163#define C6DOFIMU26_ACCEL_M_S2_TO_G 9.80665
164#define C6DOFIMU26_GYRO_LSB_RES 1600
165#define C6DOFIMU26_TEMP_LSB_RES 100
166
171#define C6DOFIMU26_ADDRESS_0 0
172#define C6DOFIMU26_ADDRESS_1 1
173#define C6DOFIMU26_ADDRESS_2 2
174#define C6DOFIMU26_ADDRESS_3 3
175#define C6DOFIMU26_ADDRESS C6DOFIMU26_ADDRESS_3
176
185#define C6DOFIMU26_SET_DATA_SAMPLE_EDGE SET_SPI_DATA_SAMPLE_EDGE
186#define C6DOFIMU26_SET_DATA_SAMPLE_MIDDLE SET_SPI_DATA_SAMPLE_MIDDLE
187 // c6dofimu26_set
189
194
199
204#define C6DOFIMU26_MAP_MIKROBUS( cfg, mikrobus ) \
205 cfg.miso = MIKROBUS( mikrobus, MIKROBUS_MISO ); \
206 cfg.mosi = MIKROBUS( mikrobus, MIKROBUS_MOSI ); \
207 cfg.sck = MIKROBUS( mikrobus, MIKROBUS_SCK ); \
208 cfg.cs = MIKROBUS( mikrobus, MIKROBUS_CS ); \
209 cfg.rst = MIKROBUS( mikrobus, MIKROBUS_RST ); \
210 cfg.dry = MIKROBUS( mikrobus, MIKROBUS_INT )
211 // c6dofimu26_map // c6dofimu26
214
219typedef struct
220{
221 // Output pins
222 digital_out_t rst;
223
224 // Input pins
225 digital_in_t dry;
226
227 // Modules
228 spi_master_t spi;
229
230 pin_name_t chip_select;
231
233
238typedef struct
239{
240 // Communication gpio pins
241 pin_name_t miso;
242 pin_name_t mosi;
243 pin_name_t sck;
244 pin_name_t cs;
245
246 // Additional gpio pins
247 pin_name_t rst;
248 pin_name_t dry;
249
250 // static variable
251 uint32_t spi_speed;
252 spi_master_mode_t spi_mode;
253 spi_master_chip_select_polarity_t cs_polarity;
254
256
261typedef struct
262{
263 float x;
264 float y;
265 float z;
266
268
280
291
297
308
323
337
349err_t c6dofimu26_write_reg ( c6dofimu26_t *ctx, uint8_t reg, uint32_t data_in );
350
362err_t c6dofimu26_read_reg ( c6dofimu26_t *ctx, uint8_t reg, uint32_t *data_out );
363
373void c6dofimu26_set_rst_pin ( c6dofimu26_t *ctx, uint8_t state );
374
384
394
405
417
429
440err_t c6dofimu26_get_temp ( c6dofimu26_t *ctx, float *temp );
441
453
454#ifdef __cplusplus
455}
456#endif
457#endif // C6DOFIMU26_H
458 // c6dofimu26
460
461// ------------------------------------------------------------------------ END
c6dofimu26_return_value_t
6DOF IMU 26 Click return value data.
Definition c6dofimu26.h:286
@ C6DOFIMU26_ERROR
Definition c6dofimu26.h:288
@ C6DOFIMU26_OK
Definition c6dofimu26.h:287
err_t c6dofimu26_write_reg(c6dofimu26_t *ctx, uint8_t reg, uint32_t data_in)
6DOF IMU 26 write register function.
err_t c6dofimu26_default_cfg(c6dofimu26_t *ctx)
6DOF IMU 26 default configuration function.
void c6dofimu26_reset_device(c6dofimu26_t *ctx)
6DOF IMU 26 reset device function.
uint8_t c6dofimu26_get_dry_pin(c6dofimu26_t *ctx)
6DOF IMU 26 get data ready pin function.
err_t c6dofimu26_get_temp(c6dofimu26_t *ctx, float *temp)
6DOF IMU 26 get temperature function.
err_t c6dofimu26_init(c6dofimu26_t *ctx, c6dofimu26_cfg_t *cfg)
6DOF IMU 26 initialization function.
void c6dofimu26_set_rst_pin(c6dofimu26_t *ctx, uint8_t state)
6DOF IMU 26 set reset pin function.
err_t c6dofimu26_read_reg(c6dofimu26_t *ctx, uint8_t reg, uint32_t *data_out)
6DOF IMU 26 read register function.
err_t c6dofimu26_get_gyro(c6dofimu26_t *ctx, c6dofimu26_axes_t *gyro)
6DOF IMU 26 get gyroscope data function.
void c6dofimu26_cfg_setup(c6dofimu26_cfg_t *cfg)
6DOF IMU 26 configuration object setup function.
err_t c6dofimu26_check_communication(c6dofimu26_t *ctx)
6DOF IMU 26 check communication function.
err_t c6dofimu26_get_accel(c6dofimu26_t *ctx, c6dofimu26_axes_t *accel)
6DOF IMU 26 get accelerometer data function.
err_t c6dofimu26_get_data(c6dofimu26_t *ctx, c6dofimu26_data_t *data_out)
6DOF IMU 26 get all sensor data function.
This file contains SPI specific macros, functions, etc.
6DOF IMU 26 Click axes data structure.
Definition c6dofimu26.h:262
float y
Definition c6dofimu26.h:264
float x
Definition c6dofimu26.h:263
float z
Definition c6dofimu26.h:265
6DOF IMU 26 Click configuration object.
Definition c6dofimu26.h:239
pin_name_t dry
Definition c6dofimu26.h:248
spi_master_chip_select_polarity_t cs_polarity
Definition c6dofimu26.h:253
pin_name_t sck
Definition c6dofimu26.h:243
spi_master_mode_t spi_mode
Definition c6dofimu26.h:252
pin_name_t mosi
Definition c6dofimu26.h:242
uint32_t spi_speed
Definition c6dofimu26.h:251
pin_name_t miso
Definition c6dofimu26.h:241
pin_name_t rst
Definition c6dofimu26.h:247
pin_name_t cs
Definition c6dofimu26.h:244
6DOF IMU 26 Click data structure.
Definition c6dofimu26.h:274
c6dofimu26_axes_t gyro
Definition c6dofimu26.h:276
c6dofimu26_axes_t accel
Definition c6dofimu26.h:275
float temperature
Definition c6dofimu26.h:277
6DOF IMU 26 Click context object.
Definition c6dofimu26.h:220
spi_master_t spi
Definition c6dofimu26.h:228
digital_in_t dry
Definition c6dofimu26.h:225
digital_out_t rst
Definition c6dofimu26.h:222
pin_name_t chip_select
Definition c6dofimu26.h:230